package com.huatai.datacenter.controller.fire;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.huatai.common.api.R;
import com.huatai.datacenter.entity.dto.RequestLogDto;
import com.huatai.datacenter.entity.dto.RequestLogStatVo;
import com.huatai.datacenter.service.RequestLogService;
import com.huatai.datacenter.service.ServerObjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "数据共享系统日志",value = "数据共享系统日志")
@RequestMapping("/fire/dataShareSystemLogs")
public class DataShareSystemLogsController {

    @Autowired
    private ServerObjectService serverObjectService;

    @Autowired
    private RequestLogService requestLogService;

    /**
     * 获取服务对象下拉框清册
     * @return
     */
    @PostMapping("/getServerObject")
    @ApiOperation("获取服务对象下拉框清册")
    public R<List<JSONObject>> getServerObject(){
        return serverObjectService.getServerObject();
    }

    @ApiOperationSupport(includeParameters = {
            "requestLogDto.page",
            "requestLogDto.limit",
            "requestLogDto.appKey",
            "requestLogDto.requestName"
    })
    @ApiOperation("获取接口请求日志清册")
    @PostMapping("/getDataShareSystemLogs")
    public R getDataShareSystemLogs(@RequestBody RequestLogDto requestLogDto){
        Page<RequestLogStatVo> page = requestLogService.getRequestLogStats(requestLogDto);
        return R.data(page);
    }

}
